//
// Created by Administrator on 2021/11/29.
//
#include "StringTest.h"
#include <iostream>
#include "../core/Log.h"

using namespace std;

void testString(){
    string a = "5412332w12555";
    cout << StringUtil::indexOf(a, '2') << endl;
    cout << StringUtil::lastIndexOf(a, '2') << endl;
    cout << StringUtil::subStr(a, 0, 3) << endl;
    cout << StringUtil::subStr(a, 2, 2) << endl;
    vector<std::string> array;
    StringUtil::split(a, "12", array);
    for (string s : array) {
        cout << s << endl;
    }
    array.clear();
    StringUtil::splitWithRegex("asha19290k213kk ksal12p", "\\d", array);
    for (string s : array) {
        cout << s << endl;
    }
    cout<< StringUtil::getFileName(__FILE__) << endl;
    cout << StringUtil::toString(12134) << endl;
    cout << StringUtil::toString(3.0192f) << endl;
    cout << StringUtil::format("我是geshihua[%d],[%s],[%f]", 11, "123", 1.2311f) << endl;
    cout << StringUtil::trim("78 2131idmai    ") << endl;
    cout << StringUtil::startWith(a, "12") << endl;
    cout << a.c_str() << endl;

    log_info("test,%f", 3.121323f);
    m_check(!StringUtil::startWith(a, "12"), StringUtil::format("%s starts with 12", a.c_str()).c_str());

    // 下边语句会抛异常
    //m_assert(StringUtil::startWith(a, "12"));
}